class Solution {
    public double average(int[] salary) {
        double sum = 0 ;
        int max ,min ; 
       sum =  max = min = salary[0] ;
        for(int i = 1 ; i<salary.length ; i++){
            if(salary[i] > max ){
                 max = salary[i] ;
            }else if(salary[i] < min){
            min = salary[i] ;
            }
            sum += salary[i] ;
        }

        sum = (sum - max - min) / (salary.length-2) ;
        return sum ;
    }
}